package com.yitongmao.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.yitongmao.bean.HistoryVersionBean;
import com.yitongmao.yitmfruit.R;

import java.util.List;

/*
* 作者：梁伟航 on 2017/8/12 12:33
* 类的用途：
*/
public class HistoryVersionAdapter extends BaseAdapter{
    private  Context context;
    private List<HistoryVersionBean.VersionInfoBean> versionInfo;
    public HistoryVersionAdapter(Context context, List<HistoryVersionBean.VersionInfoBean> versionInfo) {
        this.context=context;
        this.versionInfo=versionInfo;
    }

    @Override
    public int getCount() {
        return versionInfo.size();
    }

    @Override
    public Object getItem(int position) {
        return versionInfo.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView=View.inflate(context, R.layout.historyversionlistview,null);
            viewHolder.mVersion = (TextView) convertView.findViewById(R.id.mVersion);
            viewHolder.mVersionTime = (TextView) convertView.findViewById(R.id.mVersionTime);
            viewHolder.mVersionBody = (TextView) convertView.findViewById(R.id.mVersionBody);
            convertView.setTag(viewHolder);//绑定ViewHolder对象
        }else {
            viewHolder = (ViewHolder) convertView.getTag();
        }
        viewHolder.mVersion.setText(versionInfo.get(position).appVersionName+"版本");
        viewHolder.mVersionTime.setText(versionInfo.get(position).appDate);
        viewHolder.mVersionBody.setText(""+versionInfo.get(position).appDescribe);
        return convertView;
    }
    class ViewHolder {
        public TextView mVersion;
        public TextView mVersionTime;
        public TextView mVersionBody;
    }
}
